/***
 *@name 队列 先进先出
 *@author Administrator
 *@date 2022/1/9 21:47
 *@Description
 **/

class Queue {
    queue = {};
    length = 0;
    headIndex = 0;

    enqueue(value){
        this.queue[this.length + this.headIndex] = value;
        this.length++;
    }

    dequeue(){
        const value = this.queue[this.headIndex];
        delete this.queue[this.headIndex];
        this.length--;
        this.headIndex++;
        return value;
    }

    peek(){
        console.log(this.queue);
    }
}

const queue = new Queue();
queue.enqueue('1111111');
queue.enqueue('2222222');
queue.dequeue();
queue.peek();
